﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UofCASE.AgileProductLinerDSL.Nant.Tasks.Models;
using System.IO;

namespace APLDTests.NantTests
{
    [TestClass]
    public class TestKeyTest
    {
        ITest test;
        ITestKey key;

        [TestInitialize]
        public void setup()
        {
            test = new Test(new FileInfo("../../../APLDTests/AcceptanceTests/Feature1Test.html"));
            key = test.Key;
        }

        [TestMethod]
        public void SelectsCreatingTest()
        {
            Assert.IsTrue(key.Matches(test));
            Assert.AreEqual(test.GetHashCode(), key.GetHashCode());
        }
            
        [TestMethod]
        public void SelectsEquivelentTest()
        {
            ITest dup = new Test(new FileInfo("../../../APLDTests/AcceptanceTests/Feature1Test.html"));
            Assert.IsTrue(key.Matches(dup));
            Assert.AreEqual(dup.GetHashCode(), key.GetHashCode());
        }

        [TestMethod]
        public void RejectsUnEquivelentTest()
        {
            ITest other = new Test(new FileInfo("../../../APLDTests/AcceptanceTests/Feature2Test.html"));
            Assert.IsFalse(key.Matches(other));
            Assert.AreNotEqual(other.GetHashCode(), key.GetHashCode());
        }
    }
}
